
from django.shortcuts import render
# from .ana import ChipotleNan
from django.http import HttpResponse
from . import ana
# Create your views here.
import time


def index(request):
    index = '''
    <h1>xx同学</h1>
    <hr>
    <h2>ChipotleNal 数据分析</h2>
    <hr>
    <a href='1/'>生成每种商品销售次数的bar图</a><br>
    <a href='2/'>生成每种商品销售金额的bar图</a><br>
    <hr>
        <h2>电影类的 数据分析</h2>
    '''
    t1 = time.time()
    request.session['time'] = t1
    # return HttpResponse(index)
    context={}
    return render(request,'bootcss.html',context)

REMOTE_HOST = 'https://pyecharts.github.io/assets/js'


def index1(request):
    chipo = ana.ChipotleNan()
    # 生成每种商品的销售次数的bar图像
    bar = chipo.bar_how_many_are_sold_per_item()
    # 被封装到ana.py中
    # info=chipo.how_many_are_sold_per_item()
    #
    # bar=chipo.bar(info.index,info.quantity)

    context = dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()

    )

    return render(request, 'index.html', context)


def index2(request):
    chipo = ana.ChipotleNan()
    bar = chipo.bar_how_much_are_sold_per_item()

    context = dict(

        myechart=bar.render_embed(),

        host=REMOTE_HOST,

        script_list=bar.get_js_dependencies()

    )

    return render(request, 'index.html', context)
